<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
          -max-size-num
      r = MaxS
      
      */
      function ucFirst(str) {
        let r = "";
        //大写开关，如果true字符大写否则原样拼接
        let upper = false;
        for (let v of str) {
          if (v === "-") {
            //过滤掉-
            r += "";
            upper = true; //打开
          } else {
            r += upper ? v.toUpperCase() : v;
            upper = false; //关闭
          }
        }
        return r;
      }
      console.log(ucFirst("-max-size-num")); // MaxSizeNum
    </script>
  </body>
</html>
